function onLoad() {

}

function escondeData(names) {
	for (i = 0; i < names.length; i++) {
		var day = document.getElementById(names[i]+"_day");
		day.style.display = 'none';
		day.selectedIndex = 0;
		
		var month = document.getElementById(names[i]+"_month");
		month.style.display = 'none';
		month.selectedIndex = 0;
		
		var year = document.getElementById(names[i]+"_year");
		year.style.display = 'none';
		year.selectedIndex = 0;
	}
}


function cliquePresenca(checkBox){
	contabilizaPresenca(checkBox.checked, checkBox.getAttribute("faltas"));
	var args = "presencaId="+checkBox.name;
	args += "&presente=" + (checkBox.checked == true ? "S" : "N");
	$.ajax({
		  url: ""+window.location.protocol +"//"+ window.location.host+"/Pilates/diario/gravaPresenca",
		  dataType : "script",
		  data: args,
		  success: function(data) {
		    
		  },
		  
		});
}


function contabilizaPresenca(checked, idEditFalta){
	var faltas = $("#"+idEditFalta).val();
	faltas = parseInt(faltas);
	faltas = checked ? faltas-1 : faltas+1;
	$("#"+idEditFalta).val(faltas);
}

function getUrl( params){
	return (""+window.location.protocol +"//"+ window.location.host + window.location.pathname + "?"+ params);

}



function gerarAulas(){
	$("#divMensagem").hide();
	var dataIni = $("#dataInicial_day").val()+"/"+$("#dataInicial_month").val()+"/"+$("#dataInicial_year").val();
	var dataFin = $("#dataFinal_day").val()+"/"+$("#dataFinal_month").val()+"/"+$("#dataFinal_year").val();
	var turmaId = $("#turma").val();
	
	
	var data = "dataIni="+encodeURIComponent(dataIni);
	data += "&dataFin="+encodeURIComponent(dataFin);
	data += "&turmaId="+(turmaId == "null" ? -1 : turmaId);
	
	$.ajax({
		  url: ""+window.location.protocol +"//"+ window.location.host+"/Pilates/geracaoAula/gerar",
		  dataType : "text",
		  data: data,
		  success: function(data) {
		    eval(data);
		    var html = "<ul>";
		    for(i = 0; i < gerado.length; i++){
		    	html += "<li>"+gerado[i].msg+"</li>";
		    }
		    html += "</ul>";
		    
		    $("#mensagem").html(html);
		    $("#divMensagem").show();
		  },
		  
		});
}

